﻿@model IEnumerable<LibMS.Models.LibCategories>
@{
    ViewBag.Title = "Quản lý danh mục tài liệu";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@section Header {
    <div class="row">
        <div class="col-lg-12">
            <h1>Quản lý danh mục tài liệu <small>Thêm mới, cập nhật hoặc xóa danh mục tài liệu.</small></h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-cog home"></i>Quản trị</a></li>
                <li class="active"><i class="fa fa-table home"></i>Danh mục tài liệu</li>
            </ol>
        </div>
    </div>
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <div class="panel-title">
                    Danh sách danh mục tài liệu
                                <a id="addNew" href="#" class="btn btn-success btn-xs pull-right">Thêm mới</a>
                </div>
            </div>

            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-4 pull-right">
                        <div class="input-group pull-right" style="margin-bottom: 20px;">
                            <input type="text" id="mainSearch" class="form-control" placeholder="Tìm kiếm danh mục tài liệu">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
                            </span>
                        </div>
                    </div>
                </div>

                <table id="tableData" class="table table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Tên danh mục</th>
                            <th>Thao tác</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (Convert.ToBoolean(ViewData["success"]) == true)
                        {
                            for (int i = 0; i < Model.ToArray().Length; i++)
                            {
                            <tr>
                                <td>@(i + 1)</td>
                                <td>@Model.ToArray()[i].CategoryName</td>
                                <td>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].CategoryId"><i class="fa fa-info-circle"></i></button>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].CategoryId"><i class="fa fa-trash-o"></i></button>
                                </td>
                            </tr>
                            }
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
            </div>
            <div class="modal-body">
                <!-- CategoryId-->
                <div class="form-group">
                    <label for="mcategoryId">Id</label>
                    <input type="text" class="form-control" id="mcategoryId" disabled>
                </div>
                <!-- CategoryName-->
                <div class="form-group">
                    <label for="mcategoryName">Tên danh mục tài liệu</label>
                    <input type="text" class="form-control" id="mcategoryName" placeholder="Tên tài liệu">
                </div>
            </div>
            <div id="myModalFooter" class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Hủy</button>
                <button type="button" class="btn btn-primary">Lưu dữ liệu</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

@section JS {
    <script src="~/Scripts/App/LibCategories/AdminListCategories.js"></script>
    <script type="text/javascript">
        var total = @ViewData["total"];
        var adminListCategory = new AdminListCategory(total);
        adminListCategory.Init();
    </script>
}